/**
 * 
 */
package lt.inkredibl.iit;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.geom.Point2D;

public class Grapher
{
	private Graphics _g;
	private ICoordTransformer _zt;

	public Grapher(Graphics g, ICoordTransformer zt)
	{
		_g = g;
		_zt = zt;
	}

	public void drawMarker(Point2D p)
	{
		p = _zt.ic2ui(p);
		_g.drawOval((int)Math.round(p.getX()) - 5, (int)Math.round(p.getY()) - 5, 10, 10);
	}
	
	public void drawLine(Point2D p1, Point2D p2)
	{
		p1 = _zt.ic2ui(p1);
		p2 = _zt.ic2ui(p2);
		_g.drawLine((int)Math.round(p1.getX()), (int)Math.round(p1.getY()), (int)Math.round(p2.getX()), (int)Math.round(p2.getY()));
	}

	public void setColor(Color c)
	{
		_g.setColor(c);
	}

	public void drawNamedMarker(Point2D p, String str)
	{
		drawMarker(p);
		p = _zt.ic2ui(p);
		_g.drawString(str, (int)Math.round(p.getX()) + 5, (int)Math.round(p.getY()) + 5);
	}

	public void drawMicroMarker(Point2D pt)
	{
		pt = _zt.ic2ui(pt);
		_g.fillRect((int)Math.round(pt.getX()), (int)Math.round(pt.getY()), 1, 1);
	}

}